package com.controller;

import com.controller.vo.ResultVO;
import com.entity.Category;
import com.service.CategoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName CategoryController
 * @Description TODO
 * @Author Kx
 * @Date 2025/5/21 16:31
 * @Version 1.0
 */
@RestController
public class CategoryController extends BaseController{
    private CategoryService categoryService;

    public CategoryController(CategoryService categoryService) {
        this.categoryService = categoryService;
    }

    /**
     * @author: kx
     * @date: 2025/5/21 16:31
     * @return com.controller.vo.ResultVO<com.entity.Category>
     * @description: 查询所有商品分类信息
    */
    @GetMapping("/category/findAll")
    public ResultVO<List<Category>> findAll() {
        List<Category> categoryList = categoryService.findAll();
        return success(categoryList);
    }

    /**
     * @author: kx
     * @date: 2025/5/21 20:11
     * @param category : 商品分类信息
     * @return com.controller.vo.ResultVO<java.lang.String>
     * @description: 添加商品分类信息
    */
    @PostMapping("/category/addCategory")
    public ResultVO<String> addCategory(@RequestBody Category category) {
        categoryService.addCategory(category);
        return success("添加商品分类成功");
    }
}
